sampler TextureSampler : register(s0);
float2 Viewport;
float2 offset;


void RenderShadowMapVS(inout float4 colorPos: COLOR0, inout float2 TexCoord : TEXCOORD, inout float4 vPos : POSITION0)
{
	// Half pixel offset for correct texel centering.

	vPos.xy -= 0.5;

	// Viewport adjustment.

	vPos.xy = (vPos.xy - offset) / Viewport;

	vPos.xy *= float2(2, -2);
	
	vPos.xy -= float2(1, -1);
   
	colorPos = vPos;
}

float4 RenderShadowMapPS( float4 Position : COLOR0, float2 TexCoord : TEXCOORD0) : COLOR
{ 
    float4 color = tex2D(TextureSampler, TexCoord); 
    return float4(Position.z, Position.z, Position.z, color.a);
}

technique ShadowMapRender
{
    pass P0
    {     
        VertexShader = compile vs_2_0 RenderShadowMapVS();
        PixelShader  = compile ps_2_0 RenderShadowMapPS();
    }
}